package com.zh.elec.dao.impl;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;

import com.zh.elec.dao.UsersDao;
import com.zh.elec.dao.base.BaseDao;
import com.zh.elec.model.Users;

public class UsersDaoImpl extends BaseDao  implements UsersDao {

	@Override
	public Object save(Users obj) {
		return this.saveOrUpdate(obj);
	}

	@Override
	public Object update(Users obj) {
		return this.saveOrUpdate(obj);
	}

	@Override
	public Object getObjById(Users obj) {
		return this.get(obj.getClass(), obj);
	}

	@Override
	public Object del(Users obj) {
		this.delete(obj);
		return obj;
	}

	@Override
	public List<Users> find(String hql) {		
		return this.find(hql);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Users> findByName(String name, Object value) {
		Criteria c=getSession().createCriteria(Users.class);
		c.add(Restrictions.eq(name, value));
		return c.list();
	}

}
